﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}
<script src="~/layuinew/layui.js"></script>
<link href="~/layuinew/css/layui.css" rel="stylesheet" />
<script>
    layui.use('jquery',function(){
        var $ = layui.jquery;

        $(document).ready(function () {
            $('#generateBtn').click(function () {
                var orderNumber = generateRandomOrderNumber();
                $('#orderNumber').text('Generated Order Number: ' + orderNumber);
            });
        });

        function generateRandomOrderNumber() {
            var timestamp = new Date().getTime();
            var randomPart = Math.floor(Math.random() * 1000); // Adjust as needed

            return 'ORD' + timestamp + randomPart;
        }

        $.ajax({
            url: 'http://localhost:5174/api/Pays/AlipaySubmit', // 替换为实际获取数据的接口 URL
            type: 'get',
            data: {
                tradeNo: generateRandomOrderNumber(),
                subject: generateRandomOrderNumber(),
                totalAmount: 500,
                body: "商品详情",

            },
            success: function (res) {
                if (res.result) {

                    window.open()?.document?.write(res.formData)
                } else {
                    layui.mag(res.formData);
                }
            },
            error: function () {
                console.error('获取反填数据失败');
            }
        });
    })

  
</script>